package cn.wolfcode.crm.Service.impl;


import cn.wolfcode.crm.Service.IDepartmentService;
import cn.wolfcode.crm.domain.Department;
import cn.wolfcode.crm.mapper.DepartmentMapper;
import cn.wolfcode.crm.query.DepartmentQuery;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DepartmentServiceImpl  implements IDepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        int i = departmentMapper.deleteByPrimaryKey(id);
        return i;
    }

    @Override
    public int insert(Department record) {
        int i = departmentMapper.insert(record);
        return  i;
    }

    @Override
    public Department selectByPrimaryKey(Long id) {
        Department department = departmentMapper.selectByPrimaryKey(id);
        return department;
    }

    @Override
    public List<Department> selectAll() {
        List<Department> departmentList = departmentMapper.selectAll();
        return departmentList;
    }

    @Override
    public int updateByPrimaryKey(Department record) {
        int i = departmentMapper.updateByPrimaryKey(record);
        return i;
    }


    @Override
    public PageInfo<Department> queryForList(DepartmentQuery qo) {
        //查询结果集
        //告诉mybatis,下面紧跟的查询需要分页
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Department> list = departmentMapper.queryForList(qo);
        return new PageInfo<>(list);
    }
}




















